package com.one.controller;

import com.one.annotation.RequestPermission;
import com.one.annotation.RequestUser;
import com.one.service.BuyMemberService;
import com.one.util.RequestReturn;
import com.one.vo.UserVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;


import java.util.Map;

/**
 * @author: tzy
 * @create: 2022/1/20
 * @FileName: BuyCommentController
 * @Description: 会员购买操作入口
 */
@Slf4j
@Api(tags = "F.会员购买操作")
@RestController
public class BuyMemberController {
    @Autowired
    private BuyMemberService buyMemberService;

    /**
     * @author: tzy
     * @date: 2022/1/20
     * @return:
     * @Description: 微信支付购买会员
     */
    @RequestPermission
    @ApiOperation(value = "购买会员", notes = "根据传入的用户id和购买周数，通过微信支付购买会员")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "body", required = true, value = "商品描述"),
//            @ApiImplicitParam(name = "totalFee", required = true, value = "标价金额 ")
//    })
    @ApiImplicitParam(name = "num", required = false, value = "1周1分钱，购买会员的周数 ")
    @PostMapping("/unifiedOrder")
    public RequestReturn<Map<String, String>> wechatPayUnifiedOrder(@RequestParam(value = "num", required = false) Integer num) {
        //@RequestParam("body") String body,@RequestParam("totalFee") Integer totalFee

        //return buyMemberService.wechatPayUnifiedOrder(body,totalFee);
        return buyMemberService.wechatPayUnifiedOrder(num);
    }

    /**
     * @author: tzy
     * @date: 2022/1/22
     * @return:
     * @Description:
     */
    @ApiOperation(value = "查询会员到期时间", notes = "根据token获取获取redis中用户的会员信息")
    @GetMapping("/queryUserMemberDate")
    public RequestReturn<String> queryUserMemberDate() {
        return buyMemberService.queryUserMemberDate();
    }
}